Repository navigation
feat: quick polls, an availability link with no account - #51
Merged
Merged
Conversation
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
…d share sheet Guest links and quick polls both remember a token per code, sit in the same public frame with the same dead ends, ask for a date window and hours, and share a link. These pieces move out of the guest page and the plan form so both screens use one copy: - lib/link-memory.ts: a per-code record in localStorage that survives blocked storage; guest-token.ts becomes one instance of it. - shell/public-page.tsx: PublicFrame, DeadEnd, NextSteps, Notice and Pitch. - plans/window-fields.tsx and plans/window.ts: the date window and daily hours fields with an optional day cap, and the duration options. - invites/share.ts: shareLink, which shareInvite and shareGuestLink now use. - The heatmap and best times take an optional nameOf for full names. Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
…h guest links The guest page's "times in" card and its list of days, hours and length move to features/availability, and the token and name record becomes parseTokenMemory in lib/link-memory, so quick polls reuse them. Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Create page, poll page, dead ends and the landing page entry, in English, German, Spanish, French and Portuguese. Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
/poll makes a poll from sensible defaults with names, the seat cap and expiry folded under More options. /p/$code renders from the poll status plus a viewing or editing mode: paint and send, everyone's heatmap and ranked best times (core rankSlots), share and copy, a sent card to edit from, full and closed notices, close and delete for the creator, dead ends for expired and unknown codes, and a sign up pitch for visitors without an account. Results refresh every 15 seconds while the tab is visible and on focus. Both routes work signed out; /p/* is kept out of search engines with a robots meta tag and an X-Robots-Tag header. Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
A saffron date chip under the hero buttons, "Find a time, no sign-up", with the same tile as The night below it, and a quiet link under The night itself. Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Make a poll from the landing page signed out, copy the link, two browsers answer, the creator sees the second answer without a reload, the friend edits, the creator closes it. A full poll turns a new person away. The create page and a poll page join the accessibility audit. Each test empties the local create log first, the rate limit itself is unchanged. Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
…st save keeps one seat A first save whose reply was lost left the browser without a token, so the retry made a second answer under the same name: the first seat was orphaned, counted twice in best times and the heatmap, and used up the cap. The poll page now makes a random token (Web Crypto) for a visitor without one and keeps it in link memory, and in component state when storage is blocked, before the first save goes out. set_quick_poll_availability takes that token: one the poll does not know makes a new answer under it, a known one edits it, the creator token works as before, and a missing or malformed token is refused with invalid_quick_poll_token (22023). The return shape is unchanged and hands back the token as sent. Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
…r typed With maxDays, the first day handler pulled the last day back for every value it saw. Clearing the field threw a RangeError (addDays on an empty day), and typing a year by keyboard passed through days like 0002-06-02, which clamped the last day and then collapsed the window to one day. The pull back now waits for a real first day from today on; anything else passes through and leaves the last day alone, and the submit check refuses the window. The plan form, which has no maxDays, is unchanged. Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
Co-authored-by: Ferrin <[email protected]> Co-authored-by: noorelmosrati <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Quick polls (issue 50): anyone can make an availability poll from the landing page with no account, share its link, and everyone who opens it adds their times and sees the best ones. A poll takes at most 15 people, and the entry on the landing page is meant to be easy to find without shouting.
Deliberate decisions:
What Changed
quick_polls,quick_poll_answersandquick_poll_slots(RLS on, no policies, no grants toanonorauthenticated) plus five anon-callablesecurity definerRPCs:create_quick_poll,quick_poll_preview,set_quick_poll_availability,close_quick_pollanddelete_quick_poll. Polls take at most 15 people (default 10, minimum 2), expire after 24 hours or 7 days, and creation is rate limited in the database throughprivate.quick_poll_creates.private.event_slotsnow delegates to a newprivate.grid_slotsso plans and polls share one grid rule. Covered bysupabase/tests/36_quick_polls.test.sqland the updated01_schema.test.sql./poll(create) and/p/$code(answer, see results, share, close or delete), with/p/*marked noindex (meta tag pluspublic/_headers). The landing page gains a card under the hero buttons and a text link under the plans feature. Results refetch every 15 seconds while the tab is visible and on focus. Shared pieces (link memory, public page frame, window fields, sent card, share sheet) were extracted and the guest page now uses them. Addspackages/apiqueries and mutations,packages/corelimits, strings in all five languages, unit tests and a Playwright journey (e2e/quick-polls.spec.ts).docs/architecture.md,docs/security.md,docs/testing.md,docs/development.md, the README feature list,AGENTS.mdfiles, and the regeneratedagent-map.json, schema snapshot, database types and route tree.Closes
#50Credits: Musa (musa-kal), Ferrin (Ferrin-Y) and Noor (noorelmosrati)
Risk Assessment
Testing
Built the web app for production, served it on an isolated port (4391) against the local Supabase stack (which already carried this branch's quick poll migration; the quick polls pgTAP file passed against it), then ran the repo's quick poll journey spec plus a throwaway Playwright spec of seven adversarial and visual scenarios on desktop-chromium and mobile-chromium. All passed: landing card to create page, 15 person cap in the UI and the database, two people answering without accounts, live refresh, edit, close, full, delete, anonymous names, rate limit, token rules, no table access for anon, and a lost first-save reply on the last seat. Screenshots of each UI state were captured. Not covered: mobile-webkit, the X-Robots-Tag header from public/_headers (applied by the static host, not by vite preview; the noindex meta tag was checked in the live page), and the PR and commit metadata requirements, which belong to other phases. One first run of my own lost-reply scenario failed on a wrong button label in my test (the product correctly offered "Update my times"); the test was corrected and passed. The preview server was stopped, the build output and the temporary spec were removed from the worktree, and the create log on the local database was cleared.
Evidence: Throwaway Playwright spec that drove the extra scenarios
Evidence: Final Playwright runs
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
apps/web/src/features/quick-polls/poll-page.tsx:451- A first save whose reply is lost can leave the page telling the visitor the poll is full and their times were not saved, when the answer was in fact stored. The token a new visitor makes is written to storage and to themadeTokenref (lines 451-456), butPollPage'smemorystate stays null untilonSaved, so the 15 second refetch (line 67) keeps callingquick_poll_previewwithout a token. Sequence: a visitor takes the last seat, the save commits server side, the reply is lost (onError, not a STOPPED code, form stays). The next refetch returns statusfullwith their own answer shown as someone else's (minefalse),editingturns false (line 190),AnswerFormunmounts and theStatusCardshowsfullTitleplus theunsavednotice (lines 251-256). The retry the browser-made token exists for is no longer reachable without a reload. With storage blocked, the unmount also dropsmadeToken, so even a reload cannot recover the seat. When the seat is not the last one the same gap shows the visitor's saved answer as another person's row until they retry. Fix at the shared boundary: lift the made token intoPollPagestate when it is created (beforesave.mutate), without clearingunsaved, so every preview call carries it and the server answersopenwithminetrue.placeholderDataalready covers the query key change.🔧 Fix applied.
3 warnings still open:
apps/web/src/features/quick-polls/poll-page.tsx:451- A first save whose reply is lost can leave the page telling the visitor the poll is full and their times were not saved, when the answer was in fact stored. The token a new visitor makes is written to storage and to themadeTokenref (lines 451-456), butPollPage'smemorystate stays null untilonSaved, so the 15 second refetch (line 67) keeps callingquick_poll_previewwithout a token. Sequence: a visitor takes the last seat, the save commits server side, the reply is lost (onError, not a STOPPED code, form stays). The next refetch returns statusfullwith their own answer shown as someone else's (minefalse),editingturns false (line 190),AnswerFormunmounts and theStatusCardshowsfullTitleplus theunsavednotice (lines 251-256). The retry the browser-made token exists for is no longer reachable without a reload. With storage blocked, the unmount also dropsmadeToken, so even a reload cannot recover the seat. When the seat is not the last one the same gap shows the visitor's saved answer as another person's row until they retry. Fix at the shared boundary: lift the made token intoPollPagestate when it is created (beforesave.mutate), without clearingunsaved, so every preview call carries it and the server answersopenwithminetrue.placeholderDataalready covers the query key change.apps/web/src/features/quick-polls/poll-page.tsx:90- Introduced by fix round 1 (commit 5624686).onToken(line 462) switches the preview query to a token-keyed key at submit time. That new query has no data of its own;placeholderDataonly covers it while its status ispending(query-core 5.106queryObserver: placeholder applies only whenstatus === 'pending'). If its first fetch fails after the 2 retries,preview.datais undefined andpreview.isErroris true, so line 90 swaps the whole page for the 'Lost the signal' screen and unmountsPollandAnswerForm. Sequence: a new visitor paints times and submits on a connection that is up but failing (the exact case the browser-made token exists for); the save fails and shows its error in the form; about 3 seconds later the token-keyed preview gives up, the form and every painted time are gone, and after Retry the form comes back empty. Before round 1 the key did not change untilonSaved, so a failed refetch kept the last data and the form (the existing test 'keeps the poll and the times being painted when a refresh fails' only covers the unchanged-key case). Fix: make the token-keyed query start with the view already on screen, for example seed it withqueryClient.setQueryData(quickPollQueries.preview(supabase, code, token).queryKey, view)right beforeonToken(made), or keep the last good view inPollPageand fall back to it whenpreview.datais undefined, so a failed refetch never drops a poll that was already showing.apps/web/src/features/quick-polls/poll-page.tsx:419- The post-savequeryClient.fetchQuery(..., staleTime: 0)does not force a fresh read when a fetch for that key is already in flight:Query.fetchwithoutcancelRefetchreturns the in-flight promise (query-core 5.106query.jsfetch). Fix round 1 (commit 5624686) made this reachable on every first save:onTokenstarts the token-keyed preview fetch at the same momentsave.mutategoes out, so when the save reply lands before that preview reply,fetchQueryresolves with a preview the server may have read before the save committed. Result:onSavedsets mode toviewing, butmineis undefined, so neither theSentCard(line 270) nor the form (line 290) renders, the visitor's answer is missing from the heatmap, and for the creator the 'Your poll is ready' card stays. It heals at the next 15 second refetch, but until then the page gives no sign the answer was saved and no way to edit. Before round 1 the token key was new at this point, so the fetch was always fresh. Sibling in the same change: an edit by a returning visitor whose save reply lands while the 15 second interval refetch (line 70) is in flight shows the old slots after 'Sent'. Fix: cancel any in-flight fetch first (await queryClient.cancelQueries({ queryKey: quickPollQueries.preview(supabase, code, next.token).queryKey })beforefetchQuery), or usequeryClient.refetchQueries({ queryKey, exact: true }), whose defaultcancelRefetch: truerestarts the fetch.🔧 Fix applied.
4 issues (3 warnings, 1 info) still open:
apps/web/src/features/quick-polls/poll-page.tsx:451- A first save whose reply is lost can leave the page telling the visitor the poll is full and their times were not saved, when the answer was in fact stored. The token a new visitor makes is written to storage and to themadeTokenref (lines 451-456), butPollPage'smemorystate stays null untilonSaved, so the 15 second refetch (line 67) keeps callingquick_poll_previewwithout a token. Sequence: a visitor takes the last seat, the save commits server side, the reply is lost (onError, not a STOPPED code, form stays). The next refetch returns statusfullwith their own answer shown as someone else's (minefalse),editingturns false (line 190),AnswerFormunmounts and theStatusCardshowsfullTitleplus theunsavednotice (lines 251-256). The retry the browser-made token exists for is no longer reachable without a reload. With storage blocked, the unmount also dropsmadeToken, so even a reload cannot recover the seat. When the seat is not the last one the same gap shows the visitor's saved answer as another person's row until they retry. Fix at the shared boundary: lift the made token intoPollPagestate when it is created (beforesave.mutate), without clearingunsaved, so every preview call carries it and the server answersopenwithminetrue.placeholderDataalready covers the query key change.apps/web/src/features/quick-polls/poll-page.tsx:90- Introduced by fix round 1 (commit 5624686).onToken(line 462) switches the preview query to a token-keyed key at submit time. That new query has no data of its own;placeholderDataonly covers it while its status ispending(query-core 5.106queryObserver: placeholder applies only whenstatus === 'pending'). If its first fetch fails after the 2 retries,preview.datais undefined andpreview.isErroris true, so line 90 swaps the whole page for the 'Lost the signal' screen and unmountsPollandAnswerForm. Sequence: a new visitor paints times and submits on a connection that is up but failing (the exact case the browser-made token exists for); the save fails and shows its error in the form; about 3 seconds later the token-keyed preview gives up, the form and every painted time are gone, and after Retry the form comes back empty. Before round 1 the key did not change untilonSaved, so a failed refetch kept the last data and the form (the existing test 'keeps the poll and the times being painted when a refresh fails' only covers the unchanged-key case). Fix: make the token-keyed query start with the view already on screen, for example seed it withqueryClient.setQueryData(quickPollQueries.preview(supabase, code, token).queryKey, view)right beforeonToken(made), or keep the last good view inPollPageand fall back to it whenpreview.datais undefined, so a failed refetch never drops a poll that was already showing.apps/web/src/features/quick-polls/poll-page.tsx:419- The post-savequeryClient.fetchQuery(..., staleTime: 0)does not force a fresh read when a fetch for that key is already in flight:Query.fetchwithoutcancelRefetchreturns the in-flight promise (query-core 5.106query.jsfetch). Fix round 1 (commit 5624686) made this reachable on every first save:onTokenstarts the token-keyed preview fetch at the same momentsave.mutategoes out, so when the save reply lands before that preview reply,fetchQueryresolves with a preview the server may have read before the save committed. Result:onSavedsets mode toviewing, butmineis undefined, so neither theSentCard(line 270) nor the form (line 290) renders, the visitor's answer is missing from the heatmap, and for the creator the 'Your poll is ready' card stays. It heals at the next 15 second refetch, but until then the page gives no sign the answer was saved and no way to edit. Before round 1 the token key was new at this point, so the fetch was always fresh. Sibling in the same change: an edit by a returning visitor whose save reply lands while the 15 second interval refetch (line 70) is in flight shows the old slots after 'Sent'. Fix: cancel any in-flight fetch first (await queryClient.cancelQueries({ queryKey: quickPollQueries.preview(supabase, code, next.token).queryKey })beforefetchQuery), or usequeryClient.refetchQueries({ queryKey, exact: true }), whose defaultcancelRefetch: truerestarts the fetch.apps/web/src/features/quick-polls/poll-page.tsx:427- Residual edge in the round 2 code, noted for awareness only. When a first save succeeds but the read right after it fails all three tries (line 428, caught at 429),onSavedstill switches toviewingwhile the cached view (the one seeded byonTokenat line 134) has nomineanswer. Neither the SentCard (line 276) nor the form (line 296) renders, so the page gives no sign the answer was saved until the next 15 second refresh gets through; it then shows the Sent card on its own. Narrow (the network must drop between the save reply and the read) and self-healing, so no action is needed.✅ **Test** - passed
✅ No issues found.
pnpm exec supabase test db supabase/tests/000_setup.test.sql supabase/tests/36_quick_polls.test.sql(pass; confirms the local stack runs this branch's SQL)pnpm buildin apps/web with local Supabase env and VITE_APP_URL=http://localhost:4391 (exit 0), thenpnpm preview --port 4391 --strictPortE2E_PORT=4391 pnpm exec playwright test e2e/quick-polls.spec.ts --project=desktop-chromium(2 passed)E2E_PORT=4391 pnpm exec playwright test e2e/quick-polls.spec.ts e2e/zz-evidence.spec.ts --project=mobile-chromium(9 passed)E2E_PORT=4391 pnpm exec playwright test e2e/zz-evidence.spec.ts --project=desktop-chromium(first run 5 passed, 1 failed on my own wrong button label, 1 skipped; after correcting the test, the remaining 2 passed)Temporary spec kept as evidence-scenarios.spec.ts in the evidence directory; viewed landing, anonymous poll and lost-reply screenshots by eye🔧 **Document** - 1 issue found → auto-fixed ✅
apps/web/AGENTS.md:21- The route rule names only/a/$code(guest links) as signed out;/polland/p/$codeare now signed out routes too. The line is incomplete, not wrong, and AGENTS.md may only be edited to correct wrong facts, so it was left alone. A person may want to add the two quick poll routes there. docs/architecture.md and docs/development.md already state it.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Issues
Closes #50